﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KingRoad.EPM.PersonnelLogEntity;

namespace KingRoad.EPM.PersonnelLogDAL
{
    /// <summary>
    /// 作用：数据库操作实体对象基础业务封装
    /// </summary>
    /// <author>
    ///   <name>王强</name>
    ///   <date>2016年11月10日</date>
    /// </author>
    /// <typeparam name="T">实体类</typeparam>
    public interface IBaseService<T> where T : BaseEntity, new()
    {
        /// <summary>
        /// 查询表中的实体对象
        /// </summary>
        /// <param name="condition">查询条件（可以直接写SQL语句）</param>
        /// <returns></returns>
        List<T> GetEntityList(string condition=" 1=1 ");

        /// <summary>
        /// 查询表中的实体，按照分页查询
        /// </summary>
        /// <param name="numCurrentPage"></param>
        /// <param name="numPerPage"></param>
        /// <param name="orderByField"></param>
        /// <param name="totalRecord"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        List<T> GetEntityListByContion(int numCurrentPage, int numPerPage, string orderByField, out int totalRecord,
            string condition = " 1=1 ");
         /// <summary>
        /// 查询表中的实体，按照分页查询
        /// </summary>
        /// <param name="numCurrentPage"></param>
        /// <param name="numPerPage"></param>
        /// <param name="orderByField"></param>
        /// <param name="totalRecord"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        List<T> GetEntityListByContionRe(int numCurrentPage, int numPerPage, string orderByField, out int totalRecord, string condition = " 1=1 ", string desc = "desc");

        List<K> GetEntityListByContionRe<K>(int numCurrentPage, int numPerPage, string orderByField, List<K> list,
  string desc = "desc") where K : new();
        /// <summary>
        /// 根据ID获取实体对象
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        T GetEntityById(Guid id);

        /// <summary>
        /// 添加实体对象
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        int InsertEntity(T entity);

        /// <summary>
        /// 更新实体对象
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        int UpdateEntity(T entity);

        /// <summary>
        /// 删除实体对象
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        int DeleteEntity(Guid id);

        /// <summary>
        /// 删除实体对象
        /// 说明： 因Guid 类型的ID无法实现删除，所以在此添加string类型
        /// lqr
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        int DeleteEntityByStringID(string id);

        /// <summary>
        ///删除实体对象（批量删除 ）
        /// 说明： 因Guid 类型的ID无法实现删除，所以在此添加string类型
        /// lqr
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        int DeleteEntityByMultiStringID(string id);
        /// <summary>
        /// 按条件删除
        /// </summary>
        /// <param name="sql">条件</param>
        /// <returns></returns>
        int DeleteBySql(string sql);
    }
}
